package com.yuan.java.java.io;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author yuaneg 2019/1/4
 */
public class StreamUtil {


    public static String toString(InputStream inputStream) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        int result = -1;
        while ((result = inputStream.read()) != -1) {
            byteArrayOutputStream.write(result);
        }
        return new String(byteArrayOutputStream.toByteArray());
    }
}
